package com.lanyam.travel.base.dao;

import java.util.List;

import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lanyam.travel.base.entity.RoleMenu;
import com.lanyam.travel.base.entity.TravelMenu;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author rosson
 * @since 2020-03-21
 */
public interface RoleMenuMapper extends BaseMapper<RoleMenu> {

	@Select("SELECT tm.* FROM travel_menu tm LEFT JOIN role_menu rm ON rm.menu_id = tm.id WHERE rm.role_id = #{roleId} ")
	List<TravelMenu> selectMenusByRoleId(String id);
	
	@Select("SELECT tm.* FROM travel_menu tm \r\n" + 
			"LEFT JOIN role_menu rm ON rm.menu_id = tm.id \r\n" + 
			"LEFT JOIN USER u ON u.role_id = rm.role_id \r\n" + 
			"WHERE u.id = #{userId}")
	List<TravelMenu> selectMenusByUserId(String userId);

}
